#pragma once
#include <hge.h>
#include <hgeSprite.h>
#include <hgevector.h>
#include <hgeanim.h>
#include "baseGame.h"
#include <string>

using std::string;

class Image
{
public:
	Image()
	{
		m_pPosition = new hgeVector();
	}
	virtual ~Image()
	{
		delete m_pSprite;
		delete m_pPosition;
	}	

	void	Render()									{ m_pSprite->Render( m_pPosition->x, m_pPosition->y ); }
	void	Render(hgeVector* position)									{ m_pSprite->Render( position->x, position->y ); }
	void	Render(float theRotation, float theScale)	{ m_pSprite->RenderEx( m_pPosition->x, m_pPosition->y, theRotation, theScale ); }

	void	SetPosition( float x, float y )			{ m_pPosition->x = x; m_pPosition->y = y; }	// set Imageposition using float's
	void	SetPosition( hgeVector* thePosition )	{ m_pPosition = thePosition; }				// ...or a Vector, your choice :)

	void	SetHotSpot( hgeVector* theHotSpot )		{ m_pSprite->SetHotSpot( theHotSpot->x, theHotSpot->y ); }


	float	GetXPosition()							{ return m_pPosition->x; }//Returns the X-Position of the Image
	float	GetYPosition()							{ return m_pPosition->y; }//Returns the Y-Position of the Image
	
	void	CreateImage( string theFilename )
	{
		// Load a texture
		m_Tex = g_pHge->Texture_Load( theFilename.c_str() );

		// Create a new sprite using the texturehandler and set the size to the texturedimensions
		m_pSprite = new hgeSprite( m_Tex, 0, 0, (float)g_pHge->Texture_GetWidth(m_Tex), (float)g_pHge->Texture_GetHeight(m_Tex) );
		
		// Set default position to the middle of the screen
		SetPosition(	g_pHge->System_GetState(HGE_SCREENWIDTH) / 2 - m_pSprite->GetWidth() / 2, 
						g_pHge->System_GetState(HGE_SCREENHEIGHT) / 2 - m_pSprite->GetHeight() / 2 );
		
	}



	float	getSpriteWidth()	{ return m_pSprite->GetWidth();} 
	float	getSpriteHeight()	{ return m_pSprite->GetHeight();} 

	hgeSprite* getSprite()		{ return m_pSprite; }

private:
	hgeSprite*	m_pSprite;				
	HTEXTURE	m_Tex;			// Texturehandler
	hgeVector*	m_pPosition;	// Imageposition
	hgeVector*	m_pHotSpot;

};

class Sound
{
public:
	Sound(){}
	virtual ~Sound(){}

	void CreateSound( string theFilename )
	{
		snd=g_pHge->Effect_Load( theFilename.c_str() );
	}

	void PlaySound()
	{
		g_pHge->Effect_Play( snd );
	}

	void PlaySoundLooped()
	{
		//g_pHge->Effect_PlayEx( snd,100,0,1,true);
	}

	void StopSound()
	{
		g_pHge->Channel_StopAll();
	}

	

private:

	HEFFECT snd;				//SoundHandler
	
};
/* 

            __   __
              __ \ / __
             /  \ | /  \
                 \|/
            _,.---v---._
   /\__/\  /            \
   \_  _/ /              \     ____________________
     \ \_|           @ __|   /	                    \
      \                \_  --  Under Construction..  |
       \     ,__/       /    |  Don't blame me if    |
     ~~~`~~~~~~~~~~~~~~/~~~~ |  it doesn't work :)   | 
							  \_____________________/
*/
class Animation
{
public:
	Animation(){}
	virtual ~Animation(){}

	void CreateAnimation(string theFilename, int theNumberOfFrames,float fTheFPS, float fTheImageHeight, float fTheSpeed)
	{
		m_Tex = g_pHge->Texture_Load( theFilename.c_str() );

		m_pAnim = new hgeAnimation( m_Tex,theNumberOfFrames,fTheFPS,0,0,g_pHge->Texture_GetWidth(m_Tex) / (float)theNumberOfFrames ,fTheImageHeight );

		m_pAnim->SetSpeed(fTheSpeed);

		m_pAnim->Play();	
	}

	void			Update( float fDeltaTime ){ m_pAnim->Update( fDeltaTime ); }

	void			Render( float theXPosition, float theYPosition ){ m_pAnim->Render( theXPosition, theYPosition ); }

	void			RenderEx( float theXPosition, float theYPosition, float theRotation, float theHScale, float theVScale){ m_pAnim->RenderEx( theXPosition, theYPosition, theRotation, theHScale, theVScale ); }

	hgeAnimation* getAnimation(){ return m_pAnim;}

private:

	HTEXTURE	m_Tex;			// Texturehandler
	hgeAnimation* m_pAnim;		// AnimationPointer

};
